package com.deer.wms.base.system.web.calendar;

import com.deer.wms.base.system.model.bar.BarCode;
import com.deer.wms.base.system.model.bar.BarCodeDto;
import com.deer.wms.base.system.model.calendar.Calendar;
import com.deer.wms.base.system.model.calendar.ErpRoom;
import com.deer.wms.base.system.service.calendar.CalendarService;
import com.deer.wms.base.system.service.calendar.ErpRoomService;
import com.deer.wms.common.core.controller.BaseController;
import com.deer.wms.common.core.domain.AjaxResult;
import com.deer.wms.common.core.page.TableDataInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther:
 * @Date: 2019/5/15 09:19
 * @Description:
 * @Version 1.0
 */
@Controller
@RequestMapping("/calendar")
public class CalendarController  extends BaseController {

    private String prefix = "calendar/";

    @Autowired
    ErpRoomService roomService;
    @Autowired
    private CalendarService calendarService;

    @RequiresPermissions("calendar:view")
    @GetMapping()
    public String index(ModelMap map) {
        List<ErpRoom> list = roomService.selectAll();
        map.put("roomList", list);
//        return prefix +"daywork";
        return prefix +"date";
    }

    /**
     * 显示全部信息，条件查询
     * @param
     * @return
     */
    @PostMapping("/findList")
    @ResponseBody
    @Transactional
    public TableDataInfo findList() {
        startPage();
        List<Calendar> list = calendarService.findCalendarList();
        return getDataTable(list);
    }

    /**
     * 新增
     * @param calendar
     * @return
     */
    @RequiresPermissions("calendar:add")
    @PostMapping("/insert")
    @ResponseBody
    @Transactional
    public AjaxResult insert( Calendar calendar){


        return toAjax(calendarService.saveCalendar(calendar));
    }
    /**
     * 修改保存
     */
    @RequiresPermissions("calendar:edit")
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Calendar calendar){
        return toAjax(calendarService.updateCalendar(calendar));
    }
    /**
     * 删除
     * @param ids
     * @return
     */
    @RequiresPermissions("calendar:remove")
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids){
        return toAjax(calendarService.delectCalendarByIds(ids));
    }





}
